<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>QA记录</title>
		<!-- 引入样式 -->
		<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
		<script src="../js/vue.js"></script>
		<!-- 引入组件库 -->
		<script src="https://unpkg.com/element-ui/lib/index.js"></script>
		<!-- 引入axios -->
		<script src="../js/axios.js"></script>
		<script src="../js/qs.js"></script>
		<!-- 导入jquery -->
		<script src="../js/jquery.min.js"></script>
	</head>
	<body>
		<!-- 搜索 -->
		<br />
		<div id="bigbox">
			<div style="width: 100%;margin-left: 15px;display: block;" id="app1">
				<i class="el-icon-caret-right" style="line-height: 40px;margin-right: 5px; float: left;"></i>
				<template style="margin-top: 50px;">
					<el-select v-model="allqainfor" @change="getSelectInfo()" filterable placeholder="全部数据" style="float: left;width: 120px; height: 60px;">
						<el-option v-for="item in allqaoptions" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</template>
				<i class="el-icon-search" style="line-height: 40px;float: left;margin-left: 10px; width: 50px; height: 50px;"></i>
				<!-- 搜索框 -->
				<div style="display: block;margin-left: -20px;float: left;">
					<el-input style="width: 200px;" placeholder=" " v-model="qaquestion">
						<el-button slot="append" @click="searchTheme()" style="width: 120px;">问题全文索引</el-button>
					</el-input>
				</div>
			</div>
			<!-- 统计删除 -->
			<div style="width: 100%;float: left;" id="app2">
				<div style="float: left;margin-left: 30px;">
					<p style="font-size: 13px;color: #333333;height: 30px;">FAQ：常见问题解答<!-- <a style="font-size: 12px;color: #807E7E;">&nbsp;共${page.total}条</a> --></p>
				</div>
				<div style="float: right;display: block;margin-right: 20px;margin-top: -10px;">
					<!-- 新建关怀 -->
					<el-button size="small" icon="el-icon-circle-plus" @click="getNew()" style="width: 80px;">&nbsp;新建</el-button>
					<!-- 遮罩层 -->
					<el-dialog title="FAQ：常见问题解答" :visible.sync="dialogFormVisible" width="70%" >
						<hr style="border: 0.5px solid #807E7E;margin: -15px 0px 15px;" />
						<el-form :model="qaform" :rules="qarules" ref="qaform" label-width="100px" class="demo-qaform" style="height: 580px; margin-top: 35px;">
							<el-row style="margin-left: 20px;margin-bottom: 10px;">
								<el-col :span="22">
									<el-form-item label="问题" prop="qaquestion" required>
										<el-input v-model="qaform.qaquestion"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row style="margin-left: 20px; margin-bottom: 10px;">
								<el-col :span="22">
									<el-form-item label="解答">
										<el-input v-model="qaform.qaanswer" type="textarea" autosize :autosize="{ minRows: 8 }" placeholder=""></el-input>
									</el-form-item>
								</el-col>
							</el-row>
							<!-- <el-row style="margin-left: 20px;margin-bottom: 20px;">
								<el-col :span="22">
									<el-form-item label="内部提示">
										<el-input type="textarea" autosize :autosize="{ minRows: 1 }" placeholder="" v-model="qaform.texttips"></el-input>
									</el-form-item>
								</el-col>
							</el-row> -->
							<el-row style="margin-left: 20px;margin-bottom: 10px;">
								<el-col :span="9">
									<el-form-item label="作者" disabled>
										<el-select v-model="qaform.qaauthor" clearable placeholder="未选" remote="" reserve-keyword placeholder="请输入关键词" :remote-method="qaauthorMethod" :loading="cumloading" style="width:100%">
											<i slot="prefix" class="el-input__icon el-icon-search"></i>
											<el-option v-for="item in allqaauthor" :key="item.value" :label="item.label" :value="item.value" ></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :span="13">
									<el-form-item label="创建日期" :label-width="formLabelWidth" disabled>
										<el-date-picker type="date" placeholder="" v-model="qaform.qadate" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
									</el-form-item>
								</el-col>
							</el-row>

							<el-row style="margin-left: 20px;margin-bottom: 10px;">
								<el-col :span="9">
									<el-form-item label="分类">
										<!-- <el-radio-group>
											<el-radio v-model="qaform.qaclassity" label="1387">A</el-radio>
											<el-radio v-model="qaform.qaclassity" label="1388">B</el-radio>
											<el-radio v-model="qaform.qaclassity" label="1389">C</el-radio>
											<el-radio v-model="qaform.qaclassity" label="1390">D</el-radio>
										</el-radio-group> -->
										<el-select v-model="qaform.qaclassity" clearable placeholder="未选" remote="" reserve-keyword placeholder="请输入关键词" :remote-method="qaclassityMethod" :loading="cumloading" style="width:100%">
											<i slot="prefix" class="el-input__icon el-icon-search"></i>
											<el-option v-for="item in allqaclassity" :key="item.value" :label="item.label" :value="item.value" ></el-option>
										</el-select>
										<!-- <el-tooltip content="Bottom center" placement="bottom">
											<div slot="content">数据字典</div>
											<i class="el-icon-document" id="newtooltwo" style="font-size: 18px;margin-left: 8px;"></i>
										</el-tooltip> -->
									</el-form-item>
								</el-col>
								<el-col :span="13">
									<el-form-item label="状态" :label-width="formLabelWidth">
										<el-input v-model="qaform.qastatue" disabled placeholder="正常"></el-input>
									</el-form-item>
								</el-col>
							</el-row>

							<el-form-item style="float: right;margin-top: 40px;">
								<el-button @click="dialogFormVisible = false">取 消</el-button>
								<el-button type="primary" @click="submitForm('qaform')">确定</el-button>
								<el-button @click="resetForm('qaform')">重置</el-button>
							</el-form-item>
						</el-form>
					</el-dialog>

				</div>
			</div>
			<!-- 表单 -->
			<div id="app3" style="margin-left: 10px;">
				<template>
					<el-table ref="multipleTable" tooltip-effect="dark" @selection-change="handleSelectionChange" :data="qatable"
					 border style="width: 100%;color: black;">
						<el-table-column type="selection" width="35" align="center">
						</el-table-column>
						<el-table-column prop="ID" show-overflow-tooltip width="100" label="ID" align="center">
						</el-table-column>
						<el-table-column prop="question" show-overflow-tooltip label="问题" align="center">
						</el-table-column>
						<el-table-column prop="qaclassify" show-overflow-tooltip width="140" label="分类" align="center">
						</el-table-column>
						<el-table-column prop="qastatus" show-overflow-tooltip label="状态" width="140" align="center">
						</el-table-column>
						<el-table-column prop="num" show-overflow-tooltip label="次数" width="140" align="center">
						</el-table-column>
						<el-table-column fixed="right" label="操作" width="100" align="center">
							<template slot-scope="scope">
								<el-tooltip content="Bottom center" placement="bottom">
									<div slot="content">删除</div>
									<i class="el-icon-delete" @click="deletenew(scope.row.ID)" style="margin: 0px 10px;font-size: 17px;"></i>
								</el-tooltip>
								<el-tooltip content="Bottom center" placement="bottom">
									<div slot="content">编辑</div>
									<i class="el-icon-edit" @click="updatehandleClick(scope.row)" style="font-size: 17px;"></i>
								</el-tooltip>
								<el-dialog title="提示" :visible.sync="dialogDelete" width="30%" append-to-body >
					 	 			<span>你确定要删除吗？</span>
						  				<span slot="footer" class="dialog-footer">
						   				<el-button @click="dialogDelete = false">取 消</el-button>
						   				<el-button type="primary" @click="dialogDelete = false" v-on:click="Delete" >确 定</el-button>
					 				</span>
								</el-dialog>

								<!-- 查看QA -->
								<div id="qaform" style="width: 90px;display: block; float: left;margin-left: 15px;">
									<!-- Form -->
									<el-dialog title="FAQ：常见问题解答" :visible.sync="dialogFormVisible" width="70%" append-to-body>
										<hr style="border: 0.5px solid #807E7E;margin: -15px 0px 15px;" />
										<el-form :model="qaform" :rules="qarules" ref="qaform" label-width="100px" class="demo-qaform" style="max-height: 520px;overflow: auto; margin-top: 35px;">
											<el-row style="margin-left: 20px;margin-bottom: 10px;">
												<el-col :span="22">
													<el-form-item label="问题" prop="qaquestion" required>
														<el-input v-model="qaform.qaquestion"></el-input>
													</el-form-item>
												</el-col>
											</el-row>
											<el-row style="margin-left: 20px; margin-bottom: 10px;">
												<el-col :span="22">
													<el-form-item label="解答">
														<el-input v-model="qaform.qaanswer" type="textarea" autosize placeholder=""></el-input>
													</el-form-item>
												</el-col>
											</el-row>
											<!-- <el-row style="margin-left: 20px;margin-bottom: 20px;">
												<el-col :span="22">
													<el-form-item label="内部提示">
														<el-input type="textarea" autosize :autosize="{ minRows: 1 }" placeholder="" v-model="qaform.texttips"></el-input>
													</el-form-item>
												</el-col>
											</el-row> -->
											<el-row style="margin-left: 20px;margin-bottom: 10px;">
												<el-col :span="9">
													<el-form-item label="作者" disabled>
														<el-select v-model="qaform.qaauthor" clearable placeholder="未选" remote="" reserve-keyword placeholder="请输入关键词" :remote-method="qaauthorMethod" :loading="cumloading" style="width:100%">
															<i slot="prefix" class="el-input__icon el-icon-search"></i>
															<el-option v-for="item in allqaauthor" :key="item.value" :label="item.label" :value="item.value" ></el-option>
														</el-select>
													</el-form-item>
												</el-col>
												<el-col :span="13">
													<el-form-item label="创建日期" :label-width="formLabelWidth" disabled>
														<el-date-picker type="date" placeholder="" v-model="qaform.qadate" value-format="yyyy-MM-dd" style="width: 100%;"></el-date-picker>
													</el-form-item>
												</el-col>
											</el-row>

											<el-row style="margin-left: 20px;margin-bottom: 10px;">
												<el-col :span="9">
													<el-form-item label="分类">
														<!-- <el-radio-group>
															<el-radio v-model="qaform.qaclassity" label="1387">A</el-radio>
															<el-radio v-model="qaform.qaclassity" label="1388">B</el-radio>
															<el-radio v-model="qaform.qaclassity" label="1389">C</el-radio>
															<el-radio v-model="qaform.qaclassity" label="1390">D</el-radio>
														</el-radio-group> -->
														<el-select v-model="qaform.qaclassity" clearable placeholder="未选" remote="" reserve-keyword placeholder="请输入关键词" :remote-method="qaclassityMethod" :loading="cumloading" style="width:100%">
															<i slot="prefix" class="el-input__icon el-icon-search"></i>
															<el-option v-for="item in allqaclassity" :key="item.value" :label="item.label" :value="item.value" ></el-option>
														</el-select>
														<!-- <el-tooltip content="Bottom center" placement="bottom">
															<div slot="content">数据字典</div>
															<i class="el-icon-document" id="newtooltwo" style="font-size: 18px;margin-left: 8px;"></i>
														</el-tooltip> -->
													</el-form-item>
												</el-col>
												<el-col :span="13">
													<el-form-item label="状态" :label-width="formLabelWidth">
														<el-select v-model="qaform.qastatue" clearable placeholder="未选" remote="" reserve-keyword placeholder="请输入关键词" :remote-method="qastatueMethod" :loading="cumloading" style="width:100%">
															<i slot="prefix" class="el-input__icon el-icon-search"></i>
															<el-option v-for="item in allqastatue" :key="item.value" :label="item.label" :value="item.value" ></el-option>
														</el-select>
													</el-form-item>
												</el-col>
											</el-row>

											<el-form-item style="float: right;margin-top: 40px;">
												<el-button @click="dialogFormVisible = false">取 消</el-button>
												<el-button type="primary" @click="submitForm('qaform')">确定</el-button>
												<el-button @click="resetForm('qaform')">重置</el-button>
											</el-form-item>
										</el-form>
									</el-dialog>

								</div>
							</template>
						</el-table-column>
					</el-table>
					<div style="margin-top: 10px">
						<div style="display: block; float: left;margin-left: 5px;">
							<!-- <el-tooltip content="Bottom center" placement="bottom">
								<div slot="content">批量删除</div>
								<i class="el-icon-delete" @click="batchDelete()" style="margin: 8px;font-size: 17px;"></i>
							</el-tooltip> -->
						</div>
						<!-- 分页 -->
						<div style="display: block; float: left; margin-left: 17%;">
							<el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage4" :pager-count="5"  
							 :page-sizes="[4, 6, 10, 20]" :page-size="${page.pageSize}" layout="total, sizes, prev, pager, next, jumper" :total="${page.total}">
							</el-pagination>
						</div>
						<div style="display: block; float: right;margin-right: 3%;">
							<!-- <el-tooltip content="Bottom center" placement="bottom">
								<div slot="content">打印</div>
								<el-button circle size="mini"><i class="el-icon-printer" style="font-size: 17px;"></i></el-button>&nbsp;
							</el-tooltip> -->

							<el-tooltip content="Bottom center" placement="bottom">
								<div slot="content">导出Excel</div>
								<el-button circle size="mini" @click="downloadfile"><i class="el-icon-tickets" style="font-size: 17px;"></i></el-button>
							</el-tooltip>

						</div>
					</div>
				</template>
			</div>
		</div>
		<div id="addjsdiv"></div>
		<script type="text/javascript">
			// 获取所有的qa
			var qatables = ${list};
			var pageinfo = ${pageinfo};
		</script>
		<script type="text/javascript">

		var Main = {
			data() {
				return {
					allqaoptions: [{
							value: '0',
							label: '全部数据'
						}, {
							value: '1387',
							label: '系统'
						}, {
							value: '1388',
							label: '产品'
						}, {
							value: '1389',
							label: '销售'
						}, {
							value: '1390',
							label: '服务'
					}],
					allqainfor: '',
					qaquestion: ''
				}
			},
				methods:{
					//根据选项获取表单数据
					getSelectInfo(){
							//页大小
						var pageSize= Max.pasSize;
						//查询条件状态
						var statueID=null;
						//qa主题
						var search=null;
						//表单对象
						var MainFromnew= MainFrom;
						console.log("搜索数据："+this.allqainfor.toString());
						if(this.allqainfor.toString()== "0" ){
							window.location.hash='#/aftersale/qa';
						}else{
							window.location.hash='#/aftersale/qa?statueID='+this.allqainfor;
							statueID=this.allqainfor;
						}
						this.qaquestion='';
						$.ajax({
								type: "post",
								url: "/aftersale/qa",
								data: {pageNum:1,pageSize:pageSize,statueID:statueID,search:search},
								success: function (getPage) {
										console.log("页数："+JSON.stringify(getPage));
										MainFromnew.qatable=getPage.list;
										MainFromnew.pages=getPage;
										MainFromnew.currentPage4=getPage.pageNum;
								}
						});
					},
						//根据qa主题搜索
					searchTheme(){
						//页大小
						var pageSize= Max.pasSize;
						//查询条件状态
						var statueID=null;
						//qa主题
						var search=null;
						//表单对象
						var MainFromnew= MainFrom;
						var MainTwoNew=MainTwo;
						console.log(this.allqainfor.toString());
						console.log("qa主题:"+this.qaquestion.toString());
						//判断是否根据条件筛选
						if(this.allqainfor.toString()=='0'||this.allqainfor.toString()==''){
							if(this.qaquestion==""){
								window.location.hash='#/aftersale/qa'
							}
							else{
								window.location.hash='#/aftersale/qa?search='+this.qaquestion;
								search=this.qaquestion;
							}
						}else{
							statueID=this.allqainfor;
							if(this.qaquestion==""){
								window.location.hash=window.location.hash.split('&')[0];
							}
							else{
								window.location.hash=window.location.hash.split('&')[0]+'&search='+this.qaquestion;
								search=decodeURI(this.qaquestion);
							}
						}
						$.ajax({
								type: "post",
								url: "/aftersale/qa",
								data: {pageNum:1,pageSize:pageSize,statueID:statueID,search:search},
								success: function (getPage) {
										console.log("页数："+JSON.stringify(getPage));
										MainFromnew.qatable=getPage.list;
										MainFromnew.pages=getPage;
										MainTwoNew.getNewPage=getPage;
										MainFromnew.currentPage4=getPage.pageNum;
								}
						});
					},
				},
				mounted:function(){
						var url= window.location.href;
						var url1= url.indexOf("?");
						if(url1!=-1){
							//截取每一个条件
							var urlcondition= url.substring(url1+1,url.length).split('&');
							for(var i=0;i<urlcondition.length;i++){
								
								if(urlcondition[i].split('=')[0]=="statueID"){
									this.allqainfor=decodeURI(urlcondition[i].split('=')[1]);
								}
								if(urlcondition[i].split('=')[0]=="search"){
									this.qaquestion=decodeURI(urlcondition[i].split('=')[1]);
								}
							}
						}
					
				}
		}
		var Ctor = Vue.extend(Main)
		new Ctor().$mount('#app1')


		/* 遮罩层 */
		var MainTwo = new Vue({
			el:"#app2",
			data:{
					formLabelWidth: "300px",
					formLabelWidtht: "200px",
					qaform: {
						qaquestion: '',
						qaanswer: '',
						texttips: '',
						qaauthor: '',
						qadate: new Date(),
						qaclassity: '',
						qastatue: ''
					},
					allqaclassity:[],
					allqaclassities:[],
					allqaauthor:[],
					allqaauthors:[],
					dialogFormVisible: false,
					cumloading:false,
					qarules: {
						qaquestion: [{required: true,message: '必填项',trigger: 'change'},{required: true,message: '必填项',trigger: 'blur'}]
					}
			},
			methods: {
				querySearchAsync(queryString, cb) {
					var restaurants = this.restaurants;
					var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;

					clearTimeout(this.timeout);
					this.timeout = setTimeout(() => {
						cb(results);
					}, 3000 * Math.random());
				},
				createStateFilter(queryString) {
					return (state) => {
						return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
					};
				},
				handleSelect(item) {
					console.log(item);
				},
				mounted() {
					this.restaurants = this.loadAll();
				},
				//新增获取数据
				getNew(){
					var _this=this;
					this.dialogFormVisible=true;
					axios.post("/aftersale/chooseQAOptions",

					).then(function(v) {
						console.log("回调成功，获取了服务器端返回的值v");
						console.log(v);
						//获取作者
						_this.allqaauthor= v.data.oneQAauthor.map(item => {
							return { value: item.u_id, label: item.u_name };
						});
						_this.allqaauthors=_this.allqaauthor;
						//获取当前登录用户
						_this.qaform.qaauthor=v.data.user.uId;
						//获取分类
						_this.allqaclassity= v.data.oneQAclassity.map(item => {
							return { value: item.value, label: item.label };
						});
						_this.allqaclassities=_this.allqaclassity;
					})/* .catch(function() {
						alert("出错了");
					} )*/;
				},
				//加载作者
				qaauthorMethod(query) {
					var _this=this;
					if (query !== '') {
						this.cumloading = true;
						setTimeout(() => {
							this.cumloading = false;
							this.allqaauthor = _this.allqaauthors.filter(item => {
								return item.label.toLowerCase()
								.indexOf(query.toLowerCase()) > -1;
							});
						}, 200);
					} else {
						this.uosign = [];
					}
				},
				//加载分类
				qaclassityMethod(query) {
					var _this=this;
					if (query !== '') {
						this.cumloading = true;
						setTimeout(() => {
							this.cumloading = false;
							this.allqaclassity = _this.allqaclassities.filter(item => {
								return item.label.toLowerCase()
								.indexOf(query.toLowerCase()) > -1;
							});
						}, 200);
					} else {
						this.uosign = [];
					}
				},
				/*//加载状态
			    qastatueMethod(query) {
				var _this=this;
						if (query !== '') {
							this.cumloading = true;
							setTimeout(() => {
								this.cumloading = false;
								this.allqastatue = _this.allqastatues.filter(item => {
									return item.label.toLowerCase()
										.indexOf(query.toLowerCase()) > -1;
								});
							}, 200);
						} else {
							this.uosign = [];
						}
					},*/
				submitForm(qaform) {
					//alert("添加！");
					var _this=this;
					this.$refs[qaform].validate((valid) => {
						if (valid) {
							//post提交数据
							axios.post("/aftersale/addQA",
								//参数转换
								Qs.stringify(this.qaform, {
									arrayFormat: 'brackets'
								})
								//id:
								//ajax请求成功的回调函数
							).then(function(v) {
								console.log("回调成功，获取了服务器端返回的值v");
								console.log(v);
								  _this.$message({
				           			showClose: true,
									type: 'success',
									message: '添加成功!',
									duration:3000,
									center: true
								});
				           		//延时两秒刷新
				           		setTimeout(function (){
												_this.dialogFormVisible=false;
				           			showAtRight('/aftersale/qa');
				           		}, 2000);
							}).catch(function() {
								//alert("出错了");
								_this.$message({
				           			showClose: true,
									type: 'success',
									message: '添加失败!',
									duration:3000,
									center: true
								});
							});
						} else {
							console.log('error submit!!');
							return false;
						}
					});
				},
				resetForm(formName) {
					this.$refs[formName].resetFields();
				}
			}
		})

		/* var x=0;
		  function checkallnum(){
		     x=x+1;
		     document.getElementById('count').innerHTML = x;
		  } */

		/*  表单  */
		var MainFrom=new Vue({
			el:"#app3",
			data:{
					formLabelWidth: "300px",
					allqaauthor:[],
					allqaauthors:[],
					allqaclassity:[],
					allqaclassities:[],
					allqastatue:[],
					allqastatues:[],
					qatable:qatables,
					pages: pageinfo,
					currentPage4: pageinfo.pageNum,
					multipleSelection: [],
					dialogFormVisible: false,
					cumloading:false,
					dialogDelete:false,
					formLabelWidth: "300px",
					chooseNum:[],//选中显示的记录数据
					ids:[],//批量删除id
					qaform: {
						ID:'',
						qaquestion: '',
						qaanswer: '',
						texttips: '',
						qaauthor: '',
						qadate: '',
						qaclassity: '',
						qastatue: ''
					},
					qarules: {
						qaquestion: [{required: true,message: '必填项',trigger: 'change'},{required: true,message: '必填项',trigger: 'blur'}]
					}
			},
			methods: {
				handleClick(row) {
					console.log(row);
				},
				handleSelectionChange(val) {
					this.multipleSelection = val;
				},
				handleSizeChange(val) {
							//页大小
							Max.pasSize= val;
							//查询条件状态
							var statueID=null;
							//qa主题
							var search=null;
							var MainFromnew = MainFrom;
							var MainTwoNew=MainTwo;
							//判断是否带条件;
							var url= window.location.href;
							var url1= url.indexOf("?");
							if(url1!=-1){
								//截取条件
								var urlcondition= url.substring(url1+1,url.length).split('&');
								for(var i=0;i<urlcondition.length;i++){
									
									if(urlcondition[i].split('=')[0]=="statueID"){
										statusid=decodeURI(urlcondition[i].split('=')[1]);
									}
									if(urlcondition[i].split('=')[0]=="search"){
										search=decodeURI(urlcondition[i].split('=')[1]);
									}
								}
							}
							$.ajax({
									type: "post",
									url: "/aftersale/qa",
									data: {pageNum:1,pageSize:val,statueID:statueID,search:search},
									success: function (getPage) {
											console.log("页数："+JSON.stringify(getPage));
											MainFromnew.qatable=getPage.list;
											MainFromnew.pages=getPage;
											MainTwoNew.getNewPage=getPage;
											MainFromnew.currentPage4=getPage.pageNum;
									}
							});
				},
				handleCurrentChange(val) {
							//页大小
							var pageSize= Max.pasSize;
							//查询条件状态
							var statueID=null;
							//qa主题
							var search=null;
							var MainFromnew = MainFrom;
							//判断是否带条件;
							var url= window.location.href;
							var url1= url.indexOf("?");
							if(url1!=-1){
								//截取条件
								var urlcondition= url.substring(url1+1,url.length).split('&');
								for(var i=0;i<urlcondition.length;i++){
									
									if(urlcondition[i].split('=')[0]=="statueID"){
										statusid=decodeURI(urlcondition[i].split('=')[1]);
									}
									if(urlcondition[i].split('=')[0]=="search"){
										search=decodeURI(urlcondition[i].split('=')[1]);
									}
								}
							}
							$.ajax({
									type: "post",
									url: "/aftersale/qa",
									data: {pageNum:1,pageSize:pageSize,statueID:statueID,search:search},
									success: function (getPage) {
											console.log("页数："+JSON.stringify(getPage));
											MainFromnew.qatable=getPage.list;
											MainFromnew.pages=getPage;
											MainFromnew.currentPage4=getPage.pageNum;
									}
							});
				},
				querySearchAsync(queryString, cb) {
					var restaurants = this.restaurants;
					var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;

					clearTimeout(this.timeout);
					this.timeout = setTimeout(() => {
						cb(results);
					}, 3000 * Math.random());
				},
				createStateFilter(queryString) {
					return (state) => {
						return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
					};
				},
				handleSelect(item) {
					console.log(item);
				},
				mounted() {
					this.restaurants = this.loadAll();
				},
				
				deletenew(ID){
					this.ID=ID;
					this.dialogDelete=true;
					
				},
				//删除方法
				Delete(){
					var _this=this;
					axios.get("/aftersale/deleteoneQA",
		           			//参数转换
		           			//Qs.stringify(this.form,{arrayFormat: 'brackets'})
		           			//ajax请求成功的回调函数
		           			{
								params:{
									ID:_this.ID
								}
		           			}
		          			).then(function(response){					          				
		           			console.log("回调成功，获取了服务器端返回的值v");
		           			console.log(response.data);					           		
		           		_this.restaurants=response.data;
		           		//alert("删除成功！");
		           		_this.$message({
		           			showClose: true,
							type: 'success',
							message: '删除成功!',
							duration:3000,
							center: true
						});
		           		//延时两秒刷新
		           		setTimeout(function (){
		           			window.location.href = '/aftersale/qa';
		           		}, 2000);

		           	}).catch(function(){
		           		//alert("删除失败！");
		           		_this.$message({
							type: 'error',
							message: '删除失败!',
							duration:3000,
							center: true
						});
		           	});	//这个是数据的初始化
			      },
			      
			    //打开QA遮罩层
				updatehandleClick(row) {
					this.dialogFormVisible = true;
					var _this = this;
					var id= row;
					console.log(_this);
					axios.post("/aftersale/QAOne",
						Qs.stringify( {
					   			'qa_id':row.ID,
						   },{arrayFormat: 'brackets'}) 
						/* //参数转换
						params:{
							complaintId:row.ID
						} */
						//ajax请求成功的回调函数
					).then(function(v) {
						console.log("回调成功，获取了服务器端返回的值v");
						console.log(v.data);
						console.log("作者");
						console.log(v.data.oneQAauthor);
						//获取作者
						_this.allqaauthor= v.data.oneQAauthor.map(item => {
							return { value: item.u_id, label: item.u_name };
						});
						_this.allqaauthors=_this.allqaauthor;
						//获取分类
						_this.allqaclassity= v.data.oneQAclassity.map(item => {
							return { value: item.value, label: item.label };
						});
						_this.allqaclassities=_this.allqaclassity;
						//获取状态
						_this.allqastatue= v.data.oneQAtype.map(item => {
							return { value: item.value, label: item.label };
						});
						_this.allqastatues=_this.allqastatue;
						//传值
						console.log(v.data.oneQAInfo);
						_this.qaform.ID=v.data.oneQAInfo.ID;
						_this.qaform.qaquestion=v.data.oneQAInfo.question;
						_this.qaform.qaanswer=v.data.oneQAInfo.answer;
						_this.qaform.texttips=v.data.oneQAInfo.answer;
						_this.qaform.qaauthor=v.data.oneQAInfo.u_id;
						_this.qaform.qadate=v.data.oneQAInfo.qadate;
						_this.qaform.qaclassity=v.data.oneQAInfo.classifyID;
						_this.qaform.qastatue=v.data.oneQAInfo.status;
						
					})/* .catch(function() {
						alert("出错了");
					} )*/;
					this.dialogFormVisible = true;
				},
				/*//修改点击次数
				updateNum(row){
					alert(row);
					console.log(row.ID);
					var _this=this;
					axios.get("/aftersale/updateNum",
		           			{
								params:{
									ID:row.ID
								}
		           			}
		          			).then(function(response){					          				
		           			console.log("回调成功，获取了服务器端返回的值v");
		           			console.log(response.data);					           		
		           		_this.restaurants=response.data;
		           		_this.$message({
		           			showClose: true,
							type: 'success',
							message: '修改成功!',
							duration:3000,
							center: true
						});
		           	}).catch(function(){
		           		_this.$message({
							type: 'error',
							message: '修改失败!',
							duration:3000,
							center: true
						});
		           	});	//这个是数据的初始化
				},*/
				//加载作者
				qaauthorMethod(query) {
					var _this=this;
					if (query !== '') {
						this.cumloading = true;
						setTimeout(() => {
							this.cumloading = false;
							this.allqaauthor = _this.allqaauthors.filter(item => {
								return item.label.toLowerCase()
								.indexOf(query.toLowerCase()) > -1;
							});
						}, 200);
					} else {
						this.uosign = [];
					}
				},
				//加载分类
				qaclassityMethod(query) {
					var _this=this;
					if (query !== '') {
						this.cumloading = true;
						setTimeout(() => {
							this.cumloading = false;
							this.allqaclassity = _this.allqaclassities.filter(item => {
								return item.label.toLowerCase()
								.indexOf(query.toLowerCase()) > -1;
							});
						}, 200);
					} else {
						this.uosign = [];
					}
				},
				//加载状态
				qastatueMethod(query) {
			var _this=this;
					if (query !== '') {
						this.cumloading = true;
						setTimeout(() => {
							this.cumloading = false;
							this.allqastatue = _this.allqastatues.filter(item => {
								return item.label.toLowerCase()
									.indexOf(query.toLowerCase()) > -1;
							});
						}, 200);
					} else {
						this.uosign = [];
					}
				},
					//表单提交修改
					submitForm(qaform) {
						var _this=this;
						this.$refs[qaform].validate((valid) => {
							if (valid) {
								//post提交数据
								axios.post("/aftersale/updateQA",
									//参数转换
									Qs.stringify(this.qaform, {
										arrayFormat: 'brackets'
									})
									//id:
									//ajax请求成功的回调函数
								).then(function(v) {
									console.log("回调成功，获取了服务器端返回的值v");
									console.log(v);
									  _this.$message({
					           			showClose: true,
										type: 'success',
										message: '修改成功!',
										duration:3000,
										center: true
									});
					           		//延时两秒刷新
					           		setTimeout(function (){
													_this.dialogFormVisible=false;
					           			showAtRight('/aftersale/qa');
					           		}, 1000);
								}).catch(function() {
									//alert("出错了");
									_this.$message({
					           			showClose: true,
										type: 'success',
										message: '修改失败!',
										duration:3000,
										center: true
									});
								});
							} else {
								console.log('error submit!!');
								return false;
							}
						});
					},
					resetForm(formName) {
						this.$refs[qaform].resetFields();
					},
				 //打印
				 downloadfile(){
					window.location.href ="/aftersale/QAExcelDownloads";
				}
			}
		})

		</script>
	</body>
</html>
